package com.cuitrip.business.reminder.model;

import android.view.View;

import com.cuitrip.business.comment.CommentActivity;
import com.cuitrip.push.model.PushMessageModel;
import com.cuitrip.service.R;
import com.cuitrip.util.ResourceUtil;
import com.cuitrip.util.time.InputTime;
import com.cuitrip.util.time.OutputTime;
import com.cuitrip.util.time.TimeUtil;

/**
 * Created by ak on 15/11/5.
 */
public class TripEndViewHolder extends ReminderInfoViewHolder {


    @Override
    public void render(final PushMessageModel object) {
        serviceName.setText(object.getServiceName());
        title.setText(ResourceUtil.getString(R.string.book_popup_finish));
        if (object.getUserType() == PushMessageModel.TRAVELLER) {
            subTitle.setText(ResourceUtil.getString(R.string.book_popup_finish_desc_ft));
            firstAction.setText(ResourceUtil.getString(R.string.review_operation_review_now));
            secondAction.setVisibility(View.GONE);
            firstAction.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismiss();
                    if (mWeakHostActivity.get().isNeedChangeType()) {
                        changeType("cuitrip://comment?oid=" + object.getMessageId());

                    } else {
                        CommentActivity.start(mWeakHostActivity.get(), object.getMessageId());
                    }
                }
            });
        } else {
            subTitle.setText(ResourceUtil.getString(R.string.book_popup_finish_desc_fi));
            secondAction.setText(ResourceUtil.getString(R.string.operation_ok_2));
            firstAction.setVisibility(View.GONE);
            secondAction.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dismiss();
                }
            });

        }

        String timeFormat = TimeUtil.formatTime(
                InputTime.build(object.getServiceDate(), TimeUtil.getZeroZone()),
                OutputTime.getInstance(OutputTime.OutputType.Type_DAY, TimeUtil.getZeroZone()));
        dateText.setText(timeFormat);
        actionStatus.setText(ResourceUtil.getString(R.string.correct_icon));

    }


}
